require("../../../utils/api.js");

var t = require("../../../utils/disapi.js"), e = require("../../../wxParse/wxParse.js"), o = getApp();

Page({
    data: {
        name: "",
        phone: "",
        openid: "",
        showTips: !1
    },
    onLoad: function(n) {
        var a = this;
        console.log(n), "4" == n.stauts && a.setData({
            showTips: !0
        }), t.Distribution_putpage().then(function(t) {
            console.log(t), a.setData({
                pageInfo: t.data,
                showLoding: !0
            }),console.log(a.data.pageInfo); e.wxParse("article", "html", t.data.distribution_put_comment, a, 5);
        }), wx.setNavigationBarColor({
            frontColor: wx.getStorageSync("basic").topcolor,
            backgroundColor: wx.getStorageSync("basic").topbg
        });
        var i = o.globalData.openid;
        this.setData({
            openid: i
        });
    },
    inputChange: function(t) {
        var e = t.detail.value;
        this.setData({
            name: e
        });
    },
    phoneChange: function(t) {
        var e = t.detail.value;
        this.setData({
            phone: e
        });
    },
    codeChange: function(t) {
        var e = t.detail.value;
        this.setData({
            code: e
        });
    },
    submit: function(e) {
        var o = this.data.phone, n = this.data.name, a = this.data.code;
        if (console.log(n), console.log(o), "" == n || void 0 == n) return wx.showModal({
            title: "请输入完整信息",
            content: "请输入您的姓名",
            showCancel: !1,
            success: function(t) {
                if (t.confirm) return !1;
            }
        }), !1;
        if ("" == o || void 0 == o) return wx.showModal({
            title: "请输入完整信息",
            content: "请输入您的手机号码",
            showCancel: !1,
            success: function(t) {
                if (t.confirm) return cont = 0, !1;
            }
        }), !1;
        var i = /^1\d{10}$/;
        if (o.length < 11 || o.length > 11 || !i.test(o)) return wx.showModal({
            title: "请输入完整信息",
            content: "请输入正确的手机号码",
            showCancel: !1,
            success: function(t) {
                if (t.confirm) return !1;
            }
        }), !1;
        t.set_dis_exa({
            openid: this.data.openid,
            phone: o,
            name: n,
            code: a
        }).then(function(t) {
            if (0 == t.errno) {
                var e = t.data;
                wx.showModal({
                    title: "提示",
                    content: e.msg,
                    showCancel: !1,
                    success: function(t) {
                        if (t.confirm) return "提交成功，请等待审核" == e.msg ? wx.navigateTo({
                            url: "/pages/commission/index"
                        }) : wx.navigateTo({
                            url: "/pages/personal/personal"
                        }), !1;
                    }
                });
            }
        });
    },
    closepop: function() {
        wx.reLaunch({
            url: "/pages/personal/personal"
        });
    }
});